<template>
  <div class="order-success">
    <div class="success-container">
      <!-- 成功图标和标题 -->
      <div class="success-header">
        <i class="el-icon-circle-check"></i>
        <h2>订单提交成功</h2>
        <p class="order-no">订单号：{{ orderNo }}</p>
      </div>

      <!-- 订单信息 -->
      <div class="order-info">
        <div class="info-item">
          <span class="label">支付金额：</span>
          <span class="value price">¥{{ amount }}</span>
        </div>
        <div class="info-item">
          <span class="label">支付方式：</span>
          <span class="value">{{ payType === 1 ? '微信支付' : '支付宝' }}</span>
        </div>
        <div class="info-item">
          <span class="label">订单类型：</span>
          <span class="value">{{ orderType === 'buyNow' ? '直接购买' : '购物车结算' }}</span>
        </div>
      </div>

      <!-- 操作按钮 -->
      <div class="action-buttons">
        <el-button type="primary" @click="goToPayment">立即支付</el-button>
        <el-button @click="goToOrderDetail">查看订单</el-button>
        <el-button @click="goToHome">返回首页</el-button>
      </div>

      <!-- 温馨提示 -->
      <div class="tips">
        <h3>温馨提示</h3>
        <ul>
          <li>请在30分钟内完成支付，超时订单将自动取消</li>
          <li>支付完成后，您可以在"我的订单"中查看订单状态</li>
          <li>如有任何问题，请联系客服</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'UserOrderSuccess',
  data() {
    return {
      orderNo: '',
      amount: 0,
      payType: 1,
      orderType: 'cart'
    }
  },
  created() {
    // 从路由参数中获取订单信息
    const { orderNo, amount, payType, orderType } = this.$route.query
    this.orderNo = orderNo
    this.amount = amount
    this.payType = payType
    this.orderType = orderType
  },
  methods: {
    goToPayment() {
      // 跳转到支付页面
      this.$router.push({
        path: '/payment',
        query: {
          orderNo: this.orderNo,
          amount: this.amount,
          payType: this.payType
        }
      })
    },
    goToOrderDetail() {
      // 跳转到订单详情页
      this.$router.push({
        path: '/order/detail',
        query: { orderNo: this.orderNo }
      })
    },
    goToHome() {
      // 返回首页
      this.$router.push('/')
    }
  }
}
</script>

<style scoped>
.order-success {
  min-height: 100vh;
  background-color: #f5f7fa;
  padding: 40px 20px;
}

.success-container {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  padding: 40px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.success-header {
  text-align: center;
  margin-bottom: 40px;
}

.success-header i {
  font-size: 64px;
  color: #67c23a;
  margin-bottom: 20px;
}

.success-header h2 {
  font-size: 24px;
  color: #303133;
  margin-bottom: 10px;
}

.order-no {
  color: #909399;
  font-size: 14px;
}

.order-info {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 4px;
  margin-bottom: 40px;
}

.info-item {
  display: flex;
  margin-bottom: 15px;
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-item .label {
  width: 100px;
  color: #606266;
}

.info-item .value {
  flex: 1;
  color: #303133;
}

.info-item .price {
  color: #f56c6c;
  font-size: 18px;
  font-weight: bold;
}

.action-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 40px;
}

.tips {
  border-top: 1px solid #ebeef5;
  padding-top: 20px;
}

.tips h3 {
  font-size: 16px;
  color: #303133;
  margin-bottom: 15px;
}

.tips ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tips li {
  color: #909399;
  margin-bottom: 10px;
  line-height: 1.5;
}

.tips li:last-child {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .success-container {
    padding: 20px;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-buttons .el-button {
    width: 100%;
  }
}
</style> 